using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text;
using System.Data; 
using yq.IBase; 
using yq.Dictionary; 
using yq.Basis; 
using yq.Model.Logic;
using System.Collections; 
using Db; 
using System.Data.Common;

namespace yq.Model.Base 
{
    ///<summary>
    /// Department_List - 部门列表 - 对象基础类
    /// </summary>
    ///<typeparam name="T"></typeparam>
    public abstract class IDepartmentList<T> :ModelBase<DepartmentList> where T : DepartmentList, new()
    {
        /// <summary>
        /// 写入主键值
        /// </summary>
        /// <param name="Id">主键</param>
        protected internal override void SetKeyValue(dynamic Id)
        {
            this.DepartmentId = Id;
        }

        /// <summary>
        /// 获取主键值
        /// </summary>
        /// <returns></returns>
        protected internal override dynamic GetKeyValue()
        {
            return DepartmentId;
        }

        /// <summary>
        /// 为本对象赋值
        /// </summary>
        /// <param name="dy"></param>
        public override void SetValue(dynamic dy) 
        {
           this.DepartmentId=dy.DepartmentId;
           this.Title=dy.Title;
           this.SuperiorDep=dy.SuperiorDep;
           this.Path=dy.Path;
           this.PathCount=dy.PathCount;
           this.Version=dy.Version;
        } 

        #region 定义属性

     
         /// <summary>
        /// 部门ID
        /// </summary>
        private String _DepartmentId = "";
      
        /// <summary>
        /// 部门ID
        /// </summary>
        public String DepartmentId
        {
            get 
            {
              return   (this._DepartmentId); 
            }

            set 
            {
                    _DepartmentId= value;  
            }
        }
       
     
         /// <summary>
        /// 部门名称
        /// </summary>
        private String _Title = "";
      
        /// <summary>
        /// 部门名称
        /// </summary>
        public String Title
        {
            get 
            {
              return   (this._Title); 
            }

            set 
            {
                    _Title= value;  
            }
        }
       
     
         /// <summary>
        /// 上级部门
        /// </summary>
        private String _SuperiorDep = "";
      
        /// <summary>
        /// 上级部门
        /// </summary>
        public String SuperiorDep
        {
            get 
            {
              return   (this._SuperiorDep); 
            }

            set 
            {
                    _SuperiorDep= value;  
            }
        }
       
     
         /// <summary>
        /// 部门路径
        /// </summary>
        private String _Path = "";
      
        /// <summary>
        /// 部门路径
        /// </summary>
        public String Path
        {
            get 
            {
              return   (this._Path); 
            }

            set 
            {
                    _Path= value;  
            }
        }
       
     
         /// <summary>
        /// 路径深度
        /// </summary>
        private int _PathCount =int.MinValue;
      
        /// <summary>
        /// 路径深度
        /// </summary>
        public int PathCount
        {
            get 
            {
              return   (this._PathCount); 
            }

            set 
            {
                    _PathCount= value;  
            }
        }
       
   

      #endregion 定义属性 

          protected internal override void SetValue(DepartmentList info, DataRow row) 
          { 
               if (row == null) 
               { 
                 info.IsLoad = false; 
               }
               else 
               { 
                  info.IsLoad = true; 
                  
                  if(row["DepartmentId"]!= DBNull.Value)
                  {
                  info.DepartmentId=row["DepartmentId"].ToString();
                 }
                 
                  
                  if(row["Title"]!= DBNull.Value)
                  {
                  info.Title=row["Title"].ToString();
                 }
                 
                  
                  if(row["SuperiorDep"]!= DBNull.Value)
                  {
                  info.SuperiorDep=row["SuperiorDep"].ToString();
                 }
                 
                  
                  if(row["Path"]!= DBNull.Value)
                  {
                  info.Path=row["Path"].ToString();
                 }
                 
                  
                  if(row["PathCount"]!= DBNull.Value)
                  {
                  info.PathCount=Convert.ToInt32(row["PathCount"]);
                 }
                 
                  
                  if(row["Version"]!= DBNull.Value)
                  {
                  info.Version=row["Version"].ToString();
                 }
                 
               } 

          } 

        protected internal override void GetDbParameters(DbCommand comm, DepartmentList info, DbHelper cn) 
        { 
             
                cn.AddInParameter(comm, "@DepartmentId", DbType.String,ParameterTool.GetObj( info._DepartmentId )); 
            
             
                cn.AddInParameter(comm, "@Title", DbType.String,ParameterTool.GetObj( info._Title )); 
            
             
                cn.AddInParameter(comm, "@SuperiorDep", DbType.String,ParameterTool.GetObj( info._SuperiorDep )); 
            
             
                cn.AddInParameter(comm, "@Path", DbType.String,ParameterTool.GetObj( info._Path )); 
            
             
                cn.AddInParameter(comm, "@PathCount", DbType.Int32,ParameterTool.GetObj( info._PathCount )); 
            
                
                cn.AddInParameter(comm,"@Version", DbType.String, Guid.NewGuid().ToString());
              

                cn.AddInParameter(comm,"@_versionOdl", DbType.String, info._Version); 
                 
        } 

    } 
} 